<include file="public@header"/>
<link rel="stylesheet" href="__STATIC__/css/zTree_v3/zTreeStyle/zTreeStyle.css" type="text/css">
<script src="__STATIC__/js/echarts.js"></script>
</head>
<style>

    td input, td select {
        width: auto;
        max-width: 180px;
    }

    .form-horizontal .control-group1 {
        float: left;
        width: 15%;
        margin-bottom: 20px;
    }

    .form-horizontal .control-label {
        width: 80px;
    }

    .form-horizontal .controls {
        margin-left: 90px;
    }

    input, select, textarea, .uneditable-input {
        max-width: 580px;
        width: 100px;
        min-width: auto;
    }

    .div_service {
        width: 160px;
        height: 100px;
        border: #dedcdc solid 1px;
        border-radius: 5px;
        float: left;
        margin-right: 5px;
        margin-left: 5px;
    }

    .div_service_text {
        background-color: #1C9846;
        color: white;
        /*display:block;*/
        /*width: 100px;*/
        /*height: 25px;*/
        /*line-height: 25px;*/
        padding-left: 10px;
        margin: 10px 0 0 10px;
    }

    .div_service_sum {
        margin: 20px 0 0 60px;

    }

    /*table thead tr {*/
    /*    background: #0B90C4;*/
    /*}*/

    table tr th {
        height: 30px;
        /*color: white;*/
        padding: 0 60px 0 10px;
        text-align: center;
    }

    /*table thead tr {*/
    /*    background: #0B90C4;*/
    /*}*/
    #table1 tr td {
        max-width: 80px;
        width: auto;
        text-align: center;
    }

    /*.content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}*/
    thead tr th {
        /*border: 0 !important;*/
    }

    .table-striped > tbody > tr:nth-of-type(odd) {
        background-color: #f7f7f7;
    }

    .styles {
        width: 100%;
        margin-left: 8px;
    }

    /*.content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}*/

    #table1 table tr th, #table1 table tr td {
        height: 30px;
        line-height: 30px;
        border: #DDDDDD solid 1px;
        /*color: white;*/
        /*padding: 10px 40px 40px 10px;*/
    }

    .main_echarts {
        width: 600px;
        height: 400px;
        display: none
    }

    .main_echarts2 {
        width: 600px;
        height: 400px;
    }

    .none {
        display: none;
    }


</style>
<body>
<div>
    <div>
        <div class="js-ajax-form">
            <div style="display: none" id="categorys">

            </div>
            <table border=0 style="align-items: left;">
                <tr>
                    <td width=15% align=left valign=top style="BORDER-RIGHT: #999999 1px dashed; padding-bottom: 2%">
                        <div>
                            <input type="text" style=" width:95%; margin-bottom:5px;" class="form-control"
                                   name="name" value="" placeholder="按照墓位编号搜索"/>
                            <ul id="tree" class="ztree" style="width:260px; overflow:auto;"></ul>
                        </div>
                    </td>
                    <td width=95% align=left valign=top>
                        <div class="wrap js-check-wrap">
                            <div class="well form-search styles">
                                <label>
                                    <div id="jingbanrenId"></div>
                                </label>
                                <label style="margin-right: 30px">
                                    按葬式检索:
                                    <select class="form-control" id='cate_id' onchange='changecate_id()' style="width: 200px">
                                        <option value=''>-请选择-</option>
                                        <option value="1">商品墓</option>
                                        <option value="2">艺术墓</option>
                                        <option value="3">生态墓</option>
                                        <option value="4">节地墓</option>
                                    </select>
                                </label>

                            </select>
                                按日期检索: <input type="date" class=' form-control' id="start_time"
                                              placeholder="请输入开始时间">
                                ~
                                <input type="date" class=' form-control' id="end_time"
                                       placeholder="请输入结束时间" style="margin-right: 30px">
                                <button class="btn btn-default" onclick="typeClick(1)">本日</button>
                                <button class="btn btn-default" onclick="typeClick(2)">本周</button>
                                <button class="btn btn-default" onclick="typeClick(3)">本月</button>
                                <button class="btn btn-default" onclick="typeClick(4)" style="margin-right: 30px">本年
                                </button>
                                <input type="hidden" id="type">
                                <input type="button" id="submit" class="btn btn-primary" value="查询"/>
                                <input type="button" id="reset" class="btn btn-primary" value="重置"/>
                                <!--        <a class="btn btn-danger" href="{:url('Archives/archives')}">清空</a>-->
                            </div>
                            <div style="height: 100px" id="statusId">


                            </div>
                            <div id="main" class="main_echarts"></div>
                            <div style="padding-top: 10px">
                                &nbsp;&nbsp;<button class="btn btn-primary " onclick="tongJiClick(3)">落葬分析图</button>
                                <!--<button type="button" class="btn btn-blue nav-external animated hiding" id="loginBntId" hidden="true">点击登录...</button>-->
                                <button class="btn btn-primary " onclick="tongJiClick(2)">维保分析图</button>
                                <button class="btn btn-primary " onclick="tongJiClick(4)">维护费到期分析图</button>
                                <button class="btn btn-default " onclick="offClick()">关闭分析图</button>
                            </div>


                            <div style="margin-top: 20px;" id="table1">
                                <div class="control-group1-p div_content" style="padding-left: 8px">
                                    <!---tab页-->
                                    <ul class="nav_tabs"
                                        style="margin: 0; padding-top: 9px !important;height: 38px !important;">
                                        <li class="active" data-t="1"><a href="javascript:">客户统计</a></li>
                                        <!--                <li data-t="2"><a href="javascript:">收款历史</a></li>-->
                                    </ul>
                                    <div class="control-group1-p nav_content">
                                        <div class="content_nav">
                                            <div style="border: 1px solid #0b81c4;border-top: 0;">
                                                <div class="fixed-table-body">
                                                    <div class="fixed-table-loading" style="top: 41px; display: none;">
                                                        数据正在加载中...
                                                    </div>
                                                    <table class="table table-hover   table-striped">
                                                        <thead>
                                                        <tr>

                                                            <th style="" data-field="no">
                                                                <div class="th-inner ">序号</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="" id="">
                                                                <div>办理时间</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th style="" data-field="type">
                                                                <div class="th-inner ">业务类型</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="add_time" style="">
                                                                <div class="th-inner ">区域</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th style="" data-field="real_name">
                                                                <div class="th-inner ">具体位置</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th style="" data-field="tomb_num">
                                                                <div class="th-inner ">墓位编号</div>
                                                                <div class="fht-cell"></div>
                                                            </th>

                                                            <th class="total_price" style="" data-field="total_price">
                                                                <div class="th-inner ">购墓人</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th style="" class="" id="deceased_name"
                                                                data-field="pay_sn">
                                                                <div class="th-inner ">使用人信息</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="" id="yuyue">
                                                                <div>预约/完成时间</div>
                                                                <div class="fht-cell"></div>
                                                            </th>

                                                            <th class="" id="status">
                                                                <div class="th-inner ">状态</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="none" id="price">
                                                                <div class="th-inner ">销售价格</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="none" id="deal">
                                                                <div class="th-inner ">成交价格</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="none" id="whq_end_date">
                                                                <div class="th-inner ">到期时间</div>
                                                                <div class="fht-cell"></div>
                                                            </th>
                                                            <th class="">
                                                                <div class="th-inner ">经办人</div>
                                                                <div class="fht-cell"></div>
                                                            </th>


                                                        </tr>
                                                        </thead>
                                                        <tbody id="table">
                                                        </tbody>
                                                    </table>
                                                    <!--分页-->
                                                    <nav aria-label="Page navigation">
                                                        <ul class="pagination" id="page"></ul>
                                                    </nav>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>

</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<link href="__STATIC__/js/bootstrap-table/dist/bootstrap-table.css" rel="stylesheet"/>
<script src="__STATIC__/js/bootstrap-table/dist/bootstrap-table.js"></script>
<script src="__STATIC__/js/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript">
    var tombId = [];
    var pages = 1;
    var lastPage = 0;
    var status = 3;
    var cate_id ='';
    var jingBanRen = "";
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: true,
            selectedMulti: false
        }, check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootPId: ""
            }
        },

        callback: {
            beforeClick: function (treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                if (treeNode.isParent) {
                    zTree.expandNode(treeNode);
                    return false;
                } else {
                    var id = treeNode.id;
                    console.log(id)
                    if (id > 0) {
                        getHtml(id, treeNode);
                    }
                    return true;
                }
            },
            onCheck: zTreeOnCheck
        }
    };

    // 点击页码
    function page(val) {
        console.log(val);
        pages = val;
        findAll();
    }

    /**
     * 点击下一页
     * @returns {boolean}
     */
    function nextPage() {
        if (pages === lastPage) {
            return false;
        }
        pages = pages + 1;
        findAll();
        console.log(pages + 1)
    }

    /**
     * 选择经办人
     * */
    function changeJingBanRen() {
        jingBanRen = $("#jingbanren").val();
    }
    function changecate_id() {
        cate_id = $("#cate_id").val();
    }

    /**
     * 点击上一页
     * @returns {boolean}
     */
    function previousPage() {
        if (pages === 1) {
            return false;
        }
        pages = pages - 1;
        findAll();
        console.log(pages - 1);
    }

    function zTreeOnCheck(e, treeId, treeNode) {
        console.log(treeNode);
        if (treeNode.checked) {
            setTombId(treeNode)
        } else {
            removeTombId(treeNode);
            console.log("取消")
        }
        console.log(tombId)
    }

    // 检测data有没有值
    function ifValue(data) {
        if (!data) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * 检测tomb中有没有该id
     * */
    function empty(id) {
        var k = 0;
        for (var i = 0; i < tombId.length; i++) {
            if (tombId[i] == id) {
                k++;
            }
        }
        if (k > 0) {
            return false;
        } else {
            return true;
        }
    }


    /**
     * 取消左侧树复选框
     * */
    function removeTombId(data) {
        if (data.type != "" && ifValue(data.children)) {
            for (var i = 0; i < data.children.length; i++) {
                if (data.children[i].type != "") {
                    removeTombId(data.children[i]);
                } else {
                    if (!empty(data.children[i].id)) {
                        var index = tombId.indexOf(data.children[i].id);
                        if (index > -1) {
                            tombId.splice(index, 1);
                        }
                    }
                }
            }
        } else {
            if (!empty(data.id)) {
                var index2 = tombId.indexOf(data.id);
                if (index2 > -1) {
                    tombId.splice(index2, 1);
                }
            }
        }
    }

    // 选中左侧树复选框赋值
    function setTombId(data) {
        if (data.type != "" && ifValue(data.children)) {
            for (var i = 0; i < data.children.length; i++) {
                if (data.children[i].type != "") {
                    setTombId(data.children[i]);
                } else {
                    if (empty(data.children[i].id)) {
                        tombId.push(data.children[i].id);
                    }
                }
            }
        } else {
            if (empty(data.id)) {
                tombId.push(data.id);
            }
        }
    }

    function tankuang() {
        $('#example').popover(options)
    }

    function offClick() {
        $("#main").attr("class", "main_echarts");
    }

    /**
     * 查看统计图*/
    function tongJiClick(type) {
        $("#main").attr("class", "main_echarts2");
        if (type === 3) {
            getData(type, "落葬分析统计")
        } else if (type === 2) {
            getData(type, "维保分析统计")
        } else {
            getData(type, "维护费到期统计")
        }
    }

    function getData(type, text) {
        $.ajax({
            url: "{:url('Analysis/getData')}",
            type: "post",
            data: {type: type},
            success: function (data) {
                console.log("hh", data)
                var data2 = [];
                var month = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
                data2.push(data.data.January);
                data2.push(data.data.February);
                data2.push(data.data.March);
                data2.push(data.data.April);
                data2.push(data.data.May);
                data2.push(data.data.June);
                data2.push(data.data.July);
                data2.push(data.data.August);
                data2.push(data.data.September);
                data2.push(data.data.October);
                data2.push(data.data.November);
                data2.push(data.data.December);
                // console.log(data2)
                echar(text, month, data2);
            }
        })
    }

    /**
     * 状态块
     * @param data
     */
    function style(data, luozang, weihufei, jicun, jichu, qianmu, tuimu, weibao,lzrs) {
        var html = "";
        var luozang = luozang.count;
        var jicun = jicun.count;
        var jichu = jichu.count;
        var qianmu = qianmu.count;
        var tuimu = tuimu.count;
        var weixiu = weibao.count;
        var weihufei = lzrs.count;
        var lzrsfei = lzrs.count;
        // for (var i = 0; i < data.length; i++) {
        //     switch (data[i].col_status) {
        //         case 0:
        html += "<div class='div_service \' onclick='statuClick(3)'>";
        html += "<span class=\"div_service_text\">落葬统计</span>\n" +
            "<p class=\"div_service_sum size\">" + luozang + "单</p>\n" +
            "</div>";
        //     break;
        // case 1:
        html += "<div class='div_service \' onclick='statuClick(0)'>";
        html += "<span class=\"div_service_text\">寄存统计</span>\n" +
            "<p class=\"div_service_sum size\">" + jicun + "单</p>\n" +
            "                                        </div>";
        html += "<div class='div_service \'  onclick='statuClick(1)'>";
        html += "<span class=\"div_service_text\">寄出</span>\n" +
            "<p class=\"div_service_sum size\">" + jichu + "单</p>\n" +
            "                                        </div>";
        //     break;
        // case 2:
        html += "<div class='div_service \'  onclick='statuClick(8)'>";
        html += "<span class=\"div_service_text\">迁墓统计</span>\n" +
            "<p class=\"div_service_sum size\">" + qianmu + "单</p>\n" +
            "                                        </div>";
        //     break;
        // case 3:
        html += "<div class='div_service \'  onclick='statuClick(10)'>";
        html += "<span class=\"div_service_text\">退墓统计</span>\n" +
            "<p class=\"div_service_sum size\">" + tuimu + "单</p>\n" +
            "                                        </div>";
        //     break;
        // case 4:
        html += "<div class='div_service \'  onclick='statuClick(2)'>";
        html += "<span class=\"div_service_text\">维保统计</span>\n" +
            "<p class=\"div_service_sum size\">" + weixiu + "单</p>\n" +
            "                                        </div>";
        //     break;
        // case 5:
        html += "<div class='div_service \'  onclick='statuClick(4)'>";
        html += "<span class=\"div_service_text\">维护费到期统计</span>\n" +
            "<p class=\"div_service_sum size\">" + weihufei + "单</p>\n" +
            " </div>";
        html += "<div class='div_service \'  onclick='statuClick(5)'>";
        html += "<span class=\"div_service_text\">落葬人数统计</span>\n" +
            "<p class=\"div_service_sum size\">" + lzrsfei + "单</p>\n" +
            " </div>";
        //     break;
        // case 6:
        // break;

        // }
        // }
        $("#statusId").html(html);
    }

    /**
     * 点击状态块*/
    function statuClick(val) {
        pages = 1
        status = val;
        if (val == 10) {
            $("#price").attr("class", "");
            $("#deal").attr("class", "");
            $("#deceased_name").attr("class", "none")
            $("#status").attr("class", "none")
            $("#yuyue").attr("class", "none")
        } else if (val == 5){
            $("#price").attr("class", "none");
            $("#deal").attr("class", "none");
            $("#deceased_name").attr("class", "none")
            $("#status").attr("class", "none")
            $("#yuyue").attr("class", "none")
        } else if (val == 4) {
            $("#whq_end_date").attr("class", "");
            $("#yuyue").attr("class", "none");
        } else if (val == 2) {
            $("#yuyue").attr("class", "none");
            $("#price").attr("class", "none");
            $("#deal").attr("class", "none");
            $("#deceased_name").attr("class", "none");
            $("#whq_end_date").attr("class", "none");
            $("#status").attr("class", "")
        } else {
            $("#price").attr("class", "none");
            $("#deal").attr("class", "none");
            $("#deceased_name").attr("class", "");
            $("#yuyue").attr("class", "");
            $("#status").attr("class", "")
            $("#whq_end_date").attr("class", "none");
        }
        pages = 1;

        findAll();
    }

    // 点击指定日期按钮
    function typeClick(type) {
        console.log(type);
        $("#start_time").val("");
        $("#end_time").val("");
        $("#type").val(type);
        findAll();
    }
    /**
     * 时间字符串转日期
     * @param str
     * @returns {Date}
     */
    function stringToDate(str) {
        var tempStrs = str.split(" ");
        var dateStrs = tempStrs[0].split("-");
        var year = parseInt(dateStrs[0], 10);
        var month = parseInt(dateStrs[1], 10) - 1;
        var day = parseInt(dateStrs[2], 10);
        var date = new Date(year, month, day);
        return date;
    }

    // 查询
    $("#submit").click(function () {
        // $("#type").val("")
        findAll();
    });

    // 重置条件
    $("#reset").click(function () {
        $("#didingren").val("");
        $("#supplier").val("");
        $("#price").val("");
        $("#type").val("");
        $("#start_time").val("");
        $("#end_time").val("");
        $("#itype").val("");
        pages = 1;
        tombId = [];
        status = 3;
        findAll();
    })

    function isNull(data) {
        return data == null ? '' : data;
    }

    function echar(text, month, data) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
            title: {
                text: text
            },
            tooltip: {},
            legend: {
                data: ['单数']
            },
            xAxis: {
                data: month
            },
            yAxis: {},
            series: [{
                name: '单量',
                type: 'bar',
                data: data
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }

    function findAll() {
        var tomb = JSON.stringify(tombId);
        var param = {
            type: $("#type").val(),
            name: "",
            start_time: $("#start_time").val(),
            end_time: $("#end_time").val(),
            jingBanRen: jingBanRen,
            page: pages,
            tombId: tomb,
            status: status,
            cate_id:cate_id

        };
        console.log(param)
        $.ajax({
            url: "{:url('Analysis/serviceStatistics')}",
            type: "post",
            data: param,
            success: function (data) {
                console.log(data)
                var jingBanRenHtml = "按经办人检索：<select class=\"form-control\" id='jingbanren' onchange='changeJingBanRen()' style=\"width: 200px\"><option value=''>-请选择-</option>"
                for (var i = 0; i < data.data.jingBanRenData.length; i++) {
                    if (jingBanRen == data.data.jingBanRenData[i].id) {
                        jingBanRenHtml += "<option selected value=" + data.data.jingBanRenData[i].id + ">" + data.data.jingBanRenData[i].user_nickname + "</option>"
                    } else {
                        jingBanRenHtml += "<option value=" + data.data.jingBanRenData[i].id + ">" + data.data.jingBanRenData[i].user_nickname + "</option>"
                    }
                }
                jingBanRenHtml += "</select>";
                $("#jingbanrenId").html(jingBanRenHtml);
                console.log(data)
                console.log(666);
                var t = $("#tree");
                t = $.fn.zTree.init(t, setting, data.data.categorys);
                var zTree = $.fn.zTree.getZTreeObj("tree");
                var treeNode = zTree.getNodeByTId("");
                zTree.selectNode(zTree.getNodeByParam("tId", "", null))
                // var id = treeNode.id;
                // if (id > 0) {
                //     getHtml(id, treeNode);
                // }
                var tableHtml = "";
                var tableData = data.data.tableData.data;
                var a = 0;

                for (var k = 0; k < tableData.length; k++) {
                    a++;
                    var itype = tableData[k].itype == 1 && tableData[k].type == 0 ? '寄存' : (tableData[k].itype == 2 ? '维保' : (tableData[k].itype == 3 ? '落葬' : (tableData[k].itype == 4 ? '维护费' : (tableData[k].itype == 8 ? '迁墓' : (tableData[k].itype == 10 ? '退墓' : '寄出')))))
                    tableHtml += "<tr><td>" + a + "</td>" +
                        "<td>" + isNull(tableData[k].add_time) + "</td>" +
                        "<td>" + itype + "</td>" +
                        "<td>" + isNull(tableData[k].tomb_region) + "</td>" +
                        "<td>" + tableData[k].tomb_address + tableData[k].tomb_bit_number + "</td>" +
                        "<td>" + isNull(tableData[k].num) + "</td>" +
                        "<td>" + isNull(tableData[k].buyer_name) + "</td>";
                    if (tableData[k].itype != 10 && tableData[k].itype != 2) {
                        tableHtml += "<td>" + isNull(tableData[k].deceased_name) + "</td>";
                    }
                    if (tableData[k].itype != 4 && tableData[k].itype != 2 && tableData[k].itype != 10) {
                        if (tableData[k].sbStatus == 0 || tableData[k].sbStatus == 1 || tableData[k].sbStatus == 2) {
                            tableHtml += "<td>" + isNull(tableData[k].appointment_time) + "</td>";
                        } else {
                            tableHtml += "<td>" + isNull(tableData[k].complete_time) + "</td>";
                        }

                    }
                    if (tableData[k].itype == 3) {
                        var type = tableData[k].sbStatus == 1 ? '未确认' : (tableData[k].sbStatus == 2 ? '已确认' : (tableData[k].sbStatus == 3 ? '已完成' : ''))
                        tableHtml += "<td>" + type + "</td>";
                    } else if (tableData[k].type == 1 || tableData[k].type == 0) {
                        var type = tableData[k].sbStatus == 1 ? '未确认' : (tableData[k].sbStatus == 2 ? '已确认' : (tableData[k].sbStatus == 3 ? '已完成' : ''))
                        tableHtml += "<td>" + type + "</td>";
                    } else if (tableData[k].itype == 8) {
                        var type = tableData[k].sbStatus == 1 ? '未确认' : (tableData[k].sbStatus == 2 ? '已确认' : (tableData[k].sbStatus == 3 ? '已完成' : ''))
                        tableHtml += "<td>" + type + "</td>";
                    } else if (tableData[k].itype == 2) {
                        var type = tableData[k].sbStatus == 0 ? '已提交' : (tableData[k].sbStatus == 2 ? '已确认' : (tableData[k].sbStatus == 3 ? '已完成' : (tableData[k].sbStatus == 1 ? '未确认' : (tableData[k].sbStatus == 4 ? '已上传' : ''))))
                        tableHtml += "<td>" + type + "</td>";
                    } else if (tableData[k].itype == 4) {
                        var time = new Date().getTime();
                        var type = tableData[k].endTime < time ? '已到期' : (time - tableData[k].endTime < 2592000 ? '即将到期' : '已缴纳')
                        // var type = tableData[k].col_status == 0 ? '无产品' : (tableData[k].col_status == 1 ? '空闲' : (tableData[k].col_status == 2 ? '已认购' : (tableData[k].col_status == 3 ? '定金' : (tableData[k].col_status == 4 ? '无规划' : (tableData[k].col_status == 5 ? '购买未使用' : (tableData[k].col_status == 6 ? '部分安葬' : (tableData[k].col_status == 7 ? '全部安葬' : (tableData[k].col_status == 8 ? '迁墓中' : ''))))))))
                        tableHtml += "<td>" + type + "</td>";
                    }
                    if (tableData[k].itype == 4) {
                        tableHtml += "<td>" + isNull(tableData[k].end_time) + "</td>"
                    }

                    if (tableData[k].itype == 10) {
                        tableHtml += "<td>" + isNull(tableData[k].tom_price) + "</td>" +
                            "<td>" + isNull(tableData[k].deal_price) + "</td>"
                    }
                    tableHtml += "<td>" + isNull(tableData[k].user_nickname) + "</td>";

                }
                $("#table").html(tableHtml);
                lastPage = data.data.tableData.last_page;
                var page = "<li>\n" +
                    "                                        <a onclick='previousPage()' aria-label=\"Previous\">\n" +
                    "                                            <span aria-hidden=\"true\">&laquo;</span>\n" +
                    "                                        </a>\n" +
                    "                                    </li>";
                if (lastPage > 10) {

                }
                for (var p = 1; p < lastPage + 1; p++) {
                    page += "<li ><a  onclick='page(" + p + ")'>" + p + "</a></li>"
                }
                page += "<li>\n" +
                    "                                        <a  onclick='nextPage()' aria-label=\"Next\">\n" +
                    "                                            <span aria-hidden=\"true\">&raquo;</span>\n" +
                    "                                        </a>\n" +
                    "                                    </li>";
                $("#page").html(page);
                style(data.data.tableDataCount, data.data.luozang, data.data.weihufei, data.data.jicun, data.data.jichu, data.data.qianmu, data.data.tuimu, data.data.weibao,data.data.lzrs);
                Wind.css('treeTable');
                Wind.use('treeTable', function () {
                    $("#dnd-example").treeTable({
                        indent: 20
                    });
                });
                // console.log(data.data.luozang);


            }, error: function (err) {
                console.log("失败", err)
            }
        })
    }

    $(document).ready(function () {
        findAll();
        $("#startTime").change(function () {
            var start = stringToDate($("#startTime").val()).getTime() / 1000;
            var end = stringToDate($("#endTime").val()).getTime() / 1000;
            if (end - start > 3600 * 24 * 30) {
                alert("最大范围只能选一个月")
                $("#startTime").val("")
                $("#endTime").val("")
            }
        })
        $("#endTime").change(function () {
            var start = stringToDate($("#startTime").val()).getTime() / 1000;
            var end = stringToDate($("#endTime").val()).getTime() / 1000;
            if (end - start > 3600 * 24 * 30) {
                alert("最大范围只能选一个月")
                $("#startTime").val("")
                $("#endTime").val("")
            }
        })

    });


</script>
<script type="text/javascript" src="__STATIC__/js/zTree_v3/jquery.ztree.all.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
</body>
</html>